#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //2、链接信号与槽（谁发出信号，发出什么信号，谁处理信号，怎么处理）
    connect(ui->cmdlineEdit,SIGNAL(returnPressed()),this,SLOT(on_commitButton_clicked()));
    //3、
    connect(ui->cancelButton,&QPushButton::clicked,this,&Widget::on_cancelButton_clicked);
    //4、
    connect(ui->browseButton,&QPushButton::clicked,[this]()
    {
        QMessageBox::information(this,"信息","点击浏览");
    });
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_commitButton_clicked()//1、
{
    //获取lineed数据
    QString program = ui->cmdlineEdit->text();
    //创建process对象
    QProcess *myProcess = new QProcess(this);
    myProcess->start(program);
}

void Widget::on_cancelButton_clicked()
{
    this->close();
}

